package it.tukano.swingdeco.event;

import java.util.EventObject;

/**
 * An event that notify the state of a variable.
 * @author pgi
 * @param <V> type of the variable
 * @param <T> the type of the value
 */
public class VarEvent<V, T> extends EventObject {

    private static final long serialVersionUID = 0;

    /** The name of the variable */
    private final V var;

    /** The value of the variable */
    private final T value;

    /**
     * Initializes a var event
     * @param source the source of the vent
     * @param var the variable that has changed
     * @param value the new value of the variable
     */
    public VarEvent(Object source, V var, T value) {
        super(source);
        this.var = var;
        this.value = value;
    }

    /**
     * Returns the new value of the variable
     * @return the new value
     */
    public T getValue() {
        return value;
    }

    /**
     * Returns the mutated variable
     * @return the variable
     */
    public V getVar() {
        return var;
    }


}
